﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Faculty
{
    class Faculty
    {
        string name;
        string dean;
        List<Department> departments;

        public Faculty(string name, string dean)
        {
            this.name = name;
            this.dean = dean;
            departments = new List<Department>();
        }

        public void AddDepartment(Department department)
        {
            departments.Add(department);
        }

        public void ShowAllStudentsOfDepartment(string departmentName)
        {
            foreach (var department in departments)
            {
                if (department.GetName() == departmentName)
                {
                    department.ShowInfo();
                    return;
                }
            }
        }

        public void ShowInfo()
        {

            Console.WriteLine(this);
            Console.WriteLine();
            foreach (var department in departments)
            {
                department.ShowInfo();
            }
        }

        public void ShowStudentBetterThanCriteium(string groupName, double criterium)
        {
            foreach(var department in departments)
            {
                if (department.ShowStudentBetterThanCriteium(groupName, criterium))
                    return;
            }
            Console.WriteLine("Группа {0} отсутствует в факультете", groupName);
        }

        public void ShowStudentWorseThanCriteium(string groupName, double criterium)
        {
            foreach (var department in departments)
            {
                if (department.ShowStudentWorseThanCriteium(groupName, criterium))
                    return;
            }
            Console.WriteLine("Группа {0} отсутствует в факультете", groupName);
        }

        public void ShowAllStudentBetterThanCriteium(double criterium)
        {
            foreach (var department in departments)
                department.ShowAllStudentBetterThanCriteium(criterium);
        }

        public void ShowAllStudentWorseThanCriteium(double criterium)
        {
            foreach (var department in departments)
                department.ShowAllStudentWorseThanCriteium(criterium);
        }

        public void ShowStudentWithDebts()
        {
            foreach (var department in departments)
            {
                department.ShowAllStudentWithDebts();
            }
        }

        public void ShowStudentWithDebts(string groupName)
        {
            foreach (var department in departments)
            {
                if (department.ShowStudentWithDebts(groupName))
                    return;
            }
            Console.WriteLine("Группа {0} отсутствует в факультете", groupName);
        }

        public override string ToString()
        {
            return String.Format("Факультет \"{0}\". Декан {1}", name, dean);
        }
    }
}
